package com.fang.mmy.items.controller;

import com.fang.mmy.entity.ResponseResult;
import com.fang.mmy.entity.User;
import com.fang.mmy.items.entity.ItemVo;
import com.fang.mmy.items.feign.UserFeign;
import com.fang.mmy.items.service.ItemService;
import com.fang.mmy.items.service.lmpl.ItemServicelmpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName ItemController
 * @Author kebukeyi
 * @Date 2022/8/7 9:44
 * @Description
 * @Version 1.0.0
 */
@RestController
@RequestMapping("/item")
public class ItemController {

    @Autowired
    private ItemService itemService;

    @Autowired
    private ItemServicelmpl itemServicelmpl;

    @Autowired
    private UserFeign userFeign;

    @GetMapping("/getItemNo")
    public String getItemNo(Long userId) {
        return itemService.getItemNo(userId);
    }

    @GetMapping("/getUserFeignNo")
    public ResponseResult<User> getUserFeignNo(Long userId) {
        return userFeign.getUserNo(userId);
    }

    @GetMapping("/addItem")
    public boolean getItemNo() {
        return itemServicelmpl.addItem();
    }

    @GetMapping("/displayList")
    public List<ItemVo> displayList(Long activityId, Long userId) {
        return itemServicelmpl.displayList(activityId, userId);
    }

    /**
     * 测试 网关 负载均衡
     *
     * @return
     */
    @GetMapping("/lb")
    //@GlobalTransactional
    public String lb() {
        System.out.println("test lb");
        return "lb";
    }


}
